package JDKtest.java_lang_test.String;

public class StringTest {

    static final String str1 = "123";
    static final String str2 = "hello";
    static final char c1 = 'a';
    static final char[] data = {'a', 'b', 'c'};
    static final boolean flag = true;
    static final byte b = 1;




    public static void main(String[] args) {

//public String(StringBuilder builder) {
//            this(builder, null);
//        }

//length();
        System.out.println(str1.length());
//isBlank();
        System.out.println(str1.isBlank());//Returns true if the string is empty or contains
//isEmpty();
        System.out.println(str1.isEmpty());
//concat
        System.out.println(str1.concat(str2));//Returns a string that is the result of concatenating this string with the string argument.
//codePointAt
        System.out.println(str1.codePointAt(0));
//charAt
        char c = str1.charAt(0);
//getChars and getBytes

        char[] chars = new char[3];
        str2.getChars(0, 3, chars, 0);//java.lang.StringIndexOutOfBoundsException
        System.out.println(chars);
//equlas
        System.out.println(str1.equals(str2));
        System.out.println(str1.equals(str1));//在自身上调用了 'equals()'
        System.out.println(str1.equals(Integer.parseInt(str1)));//'equals' 位于 'String' 和 'int' 不可转换类型的对象之间

//contentEquals
        System.out.println(str1.contentEquals(str2));
        System.out.println(str1.contentEquals(str1));
//        System.out.println(str1.contentEquals());
//        System.out.println(str1.contentEquals(Integer.parseInt(str1)));//无法解析方法 'contentEquals(int)'

//compareTo
        System.out.println(str1.compareTo(str2));
//compare
//        System.out.println(String.compare(str1, str2));//static 方法只能在其包含接口上调用


//hashCode();
        System.out.println(str1.hashCode());

//indexOf();
        System.out.println(str1.indexOf(c1));
    }

}
